﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace MarioArena.HUD
{
    public static class Overlay
    {
        private static ScoreBoard scoreBoard;
        private static NotificationTray notificationTray;
        private static TimeDisplay timeDisplay;
        private static RespawnDisplay respawnDisplay;
        private static SplashMessage splashMessage;
        private static EndScreen endScreen;

        public static void LoadContent()
        {
            notificationTray = new NotificationTray();
            notificationTray.LoadContent();

            scoreBoard = new ScoreBoard();
            scoreBoard.LoadContent();

            timeDisplay = new TimeDisplay();
            timeDisplay.LoadContent();

            respawnDisplay = new RespawnDisplay();
            respawnDisplay.LoadContent();

            splashMessage = new SplashMessage();
            splashMessage.LoadContent();

            endScreen = new EndScreen();
            endScreen.LoadContent();
        }

        public static void Update(GameTime gameTime)
        {
            notificationTray.Update(gameTime);
            scoreBoard.Update(gameTime);
            timeDisplay.Update(gameTime);
            respawnDisplay.Update(gameTime);
            splashMessage.Update(gameTime);
            endScreen.Update(gameTime);
        }

        public static void Draw(SpriteBatch spriteBatch)
        {
            //draw respawn screen first, because the other elements should be in front of it.
            respawnDisplay.Draw(spriteBatch);
            notificationTray.Draw(spriteBatch);
            splashMessage.Draw(spriteBatch);
            scoreBoard.Draw(spriteBatch);
            timeDisplay.Draw(spriteBatch);
            endScreen.Draw(spriteBatch);
        }

        /// <summary>
        /// Shows a notification on the screen.
        /// </summary>
        /// <param name="notification">Notification message to show.</param>
        public static void ShowNotification(string notification)
        {
            notificationTray.AddNotification(notification);
        }

        /// <summary>
        /// Starts the time countdown on the screen.
        /// </summary>
        /// <param name="matchDurationInSeconds">Time in seconds from which to start counting down.</param>
        public static void StartTime(int matchDurationInSeconds)
        {
            timeDisplay.StartTime(matchDurationInSeconds);
        }

        /// <summary>
        /// Show respawn display on the screen, showing the time until the player respawns.
        /// </summary>
        public static void ShowRespawnDisplay()
        {
            respawnDisplay.Activate(Settings.RespawnTime);
        }

        /// <summary>
        /// Show large splash message in the middle of the screen.
        /// </summary>
        /// <param name="message"></param>
        public static void ShowSplashMessage(string message)
        {
            splashMessage.Show(message);
        }

        /// <summary>
        /// Show the endscreen.
        /// </summary>
        public static void ShowEndScreen()
        {
            endScreen.Show();
        }
    }
}
